Skip to content

libnvme: annotate public API symbols with __public#3199

Merged
igaw merged 1 commit intolinux-nvme:masterfrom
martin-belanger:libnvme-public-visibility-v3
Mar 20, 2026
Merged

libnvme: annotate public API symbols with __public#3199
igaw merged 1 commit intolinux-nvme:masterfrom
martin-belanger:libnvme-public-visibility-v3

Conversation

@martin-belanger
Copy link

@martin-belanger martin-belanger commented Mar 18, 2026

Add compiler_attributes.h defining two GCC visibility macros:

  __public  (__attribute__((visibility("default"))))
  __weak    (__attribute__((weak)))

Annotate all functions exported via libnvme.ld, libnvmf.ld, and accessors.ld with __public. This prepares libnvme for builds with -fvisibility=hidden, ensuring internal symbols are hidden by default and only explicitly annotated functions form the public ABI.

Each affected .c file now includes compiler_attributes.h and marks the relevant function definitions with __public. The accessor generator has also been updated to emit __public, so future regenerations remain consistent.

As a small related cleanup, __weak was introduced in compiler_attributes.h and applied where needed. While not strictly part of the main change, it naturally fits alongside the new attribute definitions and keeps related compiler annotations consolidated.

@martin-belanger martin-belanger force-pushed the libnvme-public-visibility-v3 branch 2 times, most recently from 99d0290 to 5884293 Compare March 18, 2026 22:21
Add compiler_attributes.h defining two GCC visibility macros:

  __public  (__attribute__((visibility("default"))))
  __weak    (__attribute__((weak)))

Annotate all functions exported via libnvme.ld, libnvmf.ld, and
accessors.ld with __public. This prepares libnvme for builds with
-fvisibility=hidden, ensuring internal symbols are hidden by default
and only explicitly annotated functions form the public ABI.

Each affected .c file now includes compiler_attributes.h and marks
the relevant function definitions with __public. The accessor generator
has also been updated to emit __public, so future regenerations remain
consistent.

As a small related cleanup, __weak was introduced in
compiler_attributes.h and applied where needed. While not strictly part
of the main change, it naturally fits alongside the new attribute
definitions and keeps related compiler annotations consolidated.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
@igaw igaw force-pushed the libnvme-public-visibility-v3 branch from 5884293 to c3eb914 Compare March 20, 2026 07:54
@igaw
Copy link
Collaborator

igaw commented Mar 20, 2026

Rebased due to merge conflicts in accessors (run update-accessors) and a two small conflicts in tree.c due to Hannes removal of two functions.

@igaw igaw merged commit eba9def into linux-nvme:master Mar 20, 2026
27 of 28 checks passed
@igaw
Copy link
Collaborator

igaw commented Mar 20, 2026

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants